package com.handong.handserialprogram.module.cofigring.showconfig;

import android.text.TextUtils;
import android.widget.TextView;

import com.handong.handserialprogram.R;
import com.handong.handserialprogram.constants.KeyConstant;
import com.handong.handserialprogram.constants.StateConstant;
import com.handong.handserialprogram.model.entities.FootRingNewEntity;
import com.handong.handserialprogram.module.base.BaseActivity;
import com.handong.handserialprogram.module.base.BasePresenter;
import com.handong.handserialprogram.module.serialport.SerialPortUtil;

/**
 * Created by userKey on 2018/6/25.
 */

public class ShowConfigAcivity extends BaseActivity {

    private TextView IpTV,portTV,simTV,soundTV,vsionTV;

    @Override
    protected int getContentViewID() {
        return R.layout.show_config_activity;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }



    @Override
    protected void initViewByID() {
        initHeaderLayout(false);
        setCenterTitle("脚环配置");
        IpTV= (TextView) findView(R.id.IpTV);
        portTV= (TextView) findView(R.id.portTV);
        simTV= (TextView) findView(R.id.simTV);
        soundTV= (TextView) findView(R.id.soundTV);
        vsionTV= (TextView) findView(R.id.vsionTV);
    }

    @Override
    protected void initViewDataRes() {
        String footRingId=getIntent().getExtras().getString(KeyConstant.PERSON_RING_ID);
        if(TextUtils.isEmpty(footRingId)){
            finish();
            showLongToast("数据异常");
            return;
        }

        FootRingNewEntity entity= SerialPortUtil.getInstance(this).findEntityFromList(footRingId);
        IpTV.setText(entity.getIp());
        portTV.setText(entity.getPort());
        simTV.setText(entity.getSim());
        vsionTV.setText(entity.getVersion());

        if(entity.getVoiceNumber()== StateConstant.alarm_escaped){
            soundTV.setText("我是逃犯");
        }else if(entity.getVoiceNumber()==StateConstant.alarm_short){
            soundTV.setText("短警报声");
        }else if(entity.getVoiceNumber()==StateConstant.alarm_long){
            soundTV.setText("长警报声");
        }

    }
}
